package com.enlorenz.common.excel;

import java.util.Date;

import org.apache.poi.ss.formula.functions.T;

import com.enlorenz.common.util.ReflectionUtils;
import com.enlorenz.common.util.TimeUtils;
import com.enlorenz.core.enu.BaseEnum;

/**
 * 数据转换属性迭代器
 * @author Karma
 */
@SuppressWarnings("hiding")
public class TransPropDataElementIterator<T> extends PropDataElementIterator<T>{
	
	public TransPropDataElementIterator(Class<T> claxx) {
		super(claxx);
	}
	
	@SuppressWarnings("rawtypes")
	@Override
	public String getDataValue(T t, String propKey) {
		Object object=ReflectionUtils.getGetterMethodValue(t, propKey);
		if(null!=object){
			if(object instanceof Date){
				return TimeUtils.format2EnViewDate((Date)object);
			}else if(object instanceof BaseEnum){
				BaseEnum be=(BaseEnum)object;
				return be.getDesp();
			}else{
				return object.toString();
			}
		}else{
			return "";
		}
	}
	
}
